﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using SapB1WebPOS.Utils;

namespace SapB1WebPOS.DAL
{
    public class ItemMasterDataBLL
    {
        public DataSet GetTop1OITM(string companyDB)
        {
            try
            {
                DataSet dt = new DataSet("OITM");
                ItemMasterDataDAO obj = new ItemMasterDataDAO();
                dt = obj.GetTop1OITM(companyDB);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public DataSet GetOITM(string companyDB)
        {
            try
            {
                DataSet dt = new DataSet("OITM");
                ItemMasterDataDAO obj = new ItemMasterDataDAO();
                dt = obj.GetOITM(companyDB);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public DataSet GetOITM(string companyDB, string keySearch)
        {
            try
            {
                DataSet dt = new DataSet("OITM");
                ItemMasterDataDAO obj = new ItemMasterDataDAO();
                dt = obj.GetOITM(companyDB, keySearch);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public DataSet GetOITMByItemCode(string companyDB, string itemCode)
        {
            try
            {
                DataSet dt = new DataSet("OITM");
                List<object> lstParam = new List<object>();
                lstParam.Add(itemCode);

                ItemMasterDataDAO obj = new ItemMasterDataDAO();
                dt = obj.GetOITMByItemCode(companyDB, itemCode);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public long CountOITM(string companyDB)
        {
            try
            {
                ItemMasterDataDAO connect = new ItemMasterDataDAO();
                return connect.CountOITM(companyDB);
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return 0;
            }
        }
    }
}